package com.meida.paotui.bus.provider.controller;

import com.meida.common.mybatis.model.*;
import com.meida.common.springmvc.base.BaseController;
import com.meida.paotui.bus.client.entity.BusCommonaddress;
import com.meida.paotui.bus.provider.service.BusCommonaddressService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


/**
 * 用户常用地址控制器
 *
 * @author flyme
 * @date 2019-11-06
 */
@RestController
@RequestMapping("/commonaddress/")
@Api(tags = "常用地址")
public class BusCommonaddressController extends BaseController<BusCommonaddressService, BusCommonaddress>  {

    @ApiOperation(value = "用户常用地址-分页列表", notes = "用户常用地址分页列表 <a href=\"#\" target='_blank'>参数说明</a>")
    @GetMapping(value = "page")
    public ResultBody pageList(@RequestParam(required = false) Map map) {
        return bizService.pageList(map);
    }

    @ApiOperation(value = "用户常用地址-列表", notes = "用户常用地址列表 <a href=\"#\" target='_blank'>参数说明</a>")
    @GetMapping(value = "list")
    public ResultBody list(@ModelAttribute(value = "listModel") ListModel listModel) {
        return bizService.listEntityMap(listModel);

    }

    @ApiOperation(value = "用户常用地址-添加", notes = "添加用户常用地址")
    @PostMapping(value = "save")
    public ResultBody save(@ModelAttribute(value = "updateModel") SaveModel saveModel) {
        return bizService.add(saveModel);
    }

    @ApiOperation(value = "用户常用地址-更新", notes = "更新用户常用地址")
    @PostMapping(value = "update")
    public ResultBody update(@ModelAttribute(value = "updateModel") UpdateModel updateModel) {
        return bizService.edit(updateModel);
    }

    @ApiOperation(value = "用户常用地址-删除", notes = "删除用户常用地址")
    @PostMapping(value = "delete")
    public ResultBody delete(@ModelAttribute(value = "deleteModel") DeleteModel deleteModel) {
        return bizService.delete(deleteModel);
    }


    @ApiOperation(value = "用户常用地址-详情", notes = "用户常用地址详情")
    @GetMapping(value = "get")
    public ResultBody get(@ModelAttribute(value = "getModel") GetModel getModel) {
        return bizService.get(getModel);
    }

    @ApiOperation(value = "用户常用地址-更新状态值", notes = "用户常用地址更新某个状态字段")
    @PostMapping(value = "setState")

    public ResultBody setState(@RequestParam(required = false) Map map, @RequestParam(value = "state") Integer state) {
            return bizService.setState(map, "state", state);
    }
}
